﻿using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Text;
using CSM.Controllers;
using System.Web.SessionState;
using CSM.Models;

namespace CSM.ashx
{

    public class Kefu_SaveMessage : IHttpHandler,IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            CustomDataContext db = new CustomDataContext();
            string Userid = "";
            if (context.Session[SystemVars.sysSessionUserId] != null)
            {
                Userid = context.Session[SystemVars.sysSessionUserId].ToString();
            }
            string id = context.Request["id"];
            string message =HttpUtility.UrlDecode(context.Request["message"]);
            TCrm_KF_CustomerSeviceInfo myrow = new TCrm_KF_CustomerSeviceInfo();
            myrow.Message = message;
            myrow.CreateTime = DateTime.Now;
            myrow.OrderID = id;
            myrow.UserID =Userid;
            db.TCrm_KF_CustomerSeviceInfo.InsertOnSubmit(myrow);

                db.SubmitChanges();
                context.Response.Clear();
                context.Response.ContentType = "application/text";
                context.Response.Write("yes");
                context.Response.End();

        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
